package j.framework.core;

import j.util.DES;
import j.util.StringUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * User: jason
 * Date: 2014/11/10 14:55
 */
public class WebRequestConfiguration implements Serializable {

    public static final String REQUEST_TYPE_GET = "get";

    public static final String REQUEST_TYPE_POST = "post";

    public static final String RESPONSE_TYPE_DEFAULT  = "default";
    public static final String RESPONSE_TYPE_FORWARD = "forward";
    public static final String RESPONSE_TYPE_ONLY_FORWARD = "only_forward";
    public static final String RESPONSE_TYPE_REDIRECT = "redirect";
    public static final String RESPONSE_TYPE_JSON = "json";
    public static final String RESPONSE_TYPE_AJAX = "ajax";
    public static final String RESPONSE_TYPE_TREE = "tree";
    public static final String RESPONSE_TYPE_DATAGRID = "datagrid";
    public static final String RESPONSE_TYPE_FORM_IFRAME = "form_i";

    public static final String GENERAL_ACTION_ALL_IN_ONE = "allInOne";
    public static final String GENERAL_ACTION_EDIT = "edit";
    public static final String GENERAL_ACTION_SAVE = "save";
    public static final String GENERAL_ACTION_DELETE = "delete";

    public String getDesId(){
        return DES.encrypt(requestId);
    }

    private String requestId;

    private String requestName;//请求名称

    private String functionId;

    private String actionId;

    private String functionName;

    private String actionName;

    private boolean checkFunctionPrivilege;

    private boolean checkActionPrivilege;

    private String requestType;

    private String responseType;

    private String url;

    private boolean usedGeneralService;

    private String beanClassName;

    private String beanClassMethodName;

    private String generalAction;

    private String entityPkGenerateKey;

    private String entityClassName;

    private String entityTrigger;

    private boolean logSupported;

    public String getRequestId() {
        return requestId;
    }
    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public String getRequestName() {
        return requestName;
    }
    public void setRequestName(String requestName) {
        this.requestName = requestName;
    }

    public String getFunctionId() {
        return functionId;
    }
    public void setFunctionId(String functionId) {
        this.functionId = functionId;
    }

    public String getActionId() {
        return actionId;
    }
    public void setActionId(String actionId) {
        this.actionId = actionId;
    }

    public String getFunctionName() {
        if(StringUtils.isNullOrEmpty(functionName)){
            return "公共模块";
        }
        return functionName;
    }
    public void setFunctionName(String functionName) {
        this.functionName = functionName;
    }

    public String getActionName() {
        if(StringUtils.isNullOrEmpty(actionName)){
            return "公共操作";
        }
        return actionName;
    }
    public void setActionName(String actionName) {
        this.actionName = actionName;
    }

    public boolean isCheckFunctionPrivilege() {
        return checkFunctionPrivilege;
    }
    public void setCheckFunctionPrivilege(boolean checkFunctionPrivilege) {
        this.checkFunctionPrivilege = checkFunctionPrivilege;
    }

    public boolean isCheckActionPrivilege() {
        return checkActionPrivilege;
    }
    public void setCheckActionPrivilege(boolean checkActionPrivilege) {
        this.checkActionPrivilege = checkActionPrivilege;
    }

    public String getRequestType() {
        return requestType;
    }
    public void setRequestType(String requestType) {
        this.requestType = requestType;
    }

    public String getResponseType() {
        return responseType;
    }
    public void setResponseType(String responseType) {
        this.responseType = responseType;
    }

    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }

    public boolean isUsedGeneralService() {
        return usedGeneralService;
    }
    public void setUsedGeneralService(boolean usedGeneralService) {
        this.usedGeneralService = usedGeneralService;
    }

    public String getBeanClassName() {
        return beanClassName;
    }
    public void setBeanClassName(String beanClassName) {
        this.beanClassName = beanClassName;
    }

    public String getBeanClassMethodName() {
        return beanClassMethodName;
    }
    public void setBeanClassMethodName(String beanClassMethodName) {
        this.beanClassMethodName = beanClassMethodName;
    }

    public String getGeneralAction() {
        return generalAction;
    }
    public void setGeneralAction(String generalAction) {
        this.generalAction = generalAction;
    }

    public String getEntityClassName() {
        return entityClassName;
    }
    public void setEntityClassName(String entityClassName) {
        this.entityClassName = entityClassName;
    }

    public String getEntityPkGenerateKey() {
        return entityPkGenerateKey;
    }
    public void setEntityPkGenerateKey(String entityPkGenerateKey) {
        this.entityPkGenerateKey = entityPkGenerateKey;
    }

    public String getEntityTrigger() {
        return entityTrigger;
    }
    public void setEntityTrigger(String entityTrigger) {
        this.entityTrigger = entityTrigger;
    }

    public boolean isLogSupported() {
        return logSupported;
    }
    public void setLogSupported(boolean logSupported) {
        this.logSupported = logSupported;
    }

    private String addedUserId;

    private Date addedTime;

    public String getAddedUserId() {
        return addedUserId;
    }

    public void setAddedUserId(String addedUserId) {
        this.addedUserId = addedUserId;
    }

    public Date getAddedTime() {
        return addedTime;
    }

    public void setAddedTime(Date addedTime) {
        this.addedTime = addedTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        WebRequestConfiguration that = (WebRequestConfiguration) o;

        if (requestId != null ? !requestId.equals(that.requestId) : that.requestId != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return requestId != null ? requestId.hashCode() : 0;
    }
}
